package com.ruoyi.system.domain;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;

import com.ruoyi.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.StringUtils;

/**
 * 问卷题目对象 investigation_question
 *
 * @author ruoyi
 * @date 2024-12-13
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("investigation_question")
public class InvestigationQuestion extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     *
     */
    @TableId(value = "id")
    private Long id;
    /**
     * 问卷id
     */
    private Long investigationId;
    /**
     * 顺序
     */
    private Long questionOrder;
    /**
     * 名称
     */
    private String name;
    /**
     * 类型：1单选、2多选、3简答
     */
    private Integer questionType;

    public JSONArray getOptions() {
        if (StringUtils.isEmpty(content)) {
            return null;
        }
        return JSON.parseArray(this.content);
    }

    public String getContent() {
        if (options != null) {
            return options.toJSONString();
        }
        return null;
    }

    /**
     * 选项
     */
    @JsonIgnore
    private String content;

    private JSONArray options;
}
